package com.wd.live.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.wd.live.base.BaseViewModel;
import com.wd.live.bean.RenZhengBean;
import com.wd.live.model.HttpUtils;
import com.wd.live.model.SpUtils;

import java.util.HashMap;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class RenZhengViewModel extends BaseViewModel {

    public RenZhengViewModel(@NonNull Application application) {
        super(application);
    }
    MutableLiveData<RenZhengBean> list=new MutableLiveData<>();
    String uid=SpUtils.getString("uid","");
    Integer userId = Integer.valueOf(uid);
    String sid=SpUtils.getString("sid","");
    public MutableLiveData<RenZhengBean> getList(String actualName,int sex,String birthday,String address,String idNumber,String office,String expireDate,String us){
        HashMap<String , Object> map = new HashMap<>();
        map.put("actualName",actualName);
        map.put("sex",sex);
        map.put("birthday",birthday);
        map.put("address",address);
        map.put("idNumber",idNumber);
        map.put("office",office);
        map.put("expireDate",expireDate);
        map.put("nationality","汉族");
        HttpUtils.getHttpUtils()
                .getApi()
                .getRenZheng(map,userId,sid,us)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<RenZhengBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(RenZhengBean value) {
                        list.postValue(value);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
                
        return list;
    }
}
